<?php
	include_once $_SERVER['DOCUMENT_ROOT'] . '/projet_mosquee/AMC/conf/conf.site.inc.php';
	// include_once $_SERVER['DOCUMENT_ROOT'] . '/inscriptions/conf/conf.site.inc.php';

	include_once PARENT_CLASS;

	$parent = new parent_class ();

	switch ($_POST["action"]) {
		case "new_parent" :
			$nom = $_POST["inscription_nom"];
			$prenom = $_POST["inscription_prenom"];
			$email = $_POST["inscription_email"];
			$numTel = $_POST["inscription_tel"];
			$adresse = $_POST["inscription_adresse"];
			$login = $_POST["inscription_login"];
			$password = $_POST["inscription_password"];
			
			$idUser = $parent->createNewUser($login, $password, $email, $nom, $prenom);
                        if($idUser) {
                            $idParent = $parent->createNewParent($idUser, $numTel, $adresse);
                            $res = array("NOM" => $nom,
                                        "PRENOM" => $prenom,
                                        "ID_PARENT" => $idParent);
                        }
                        else {
                            $res = array("CODE_RETOUR" => 0);
                            echo json_encode($res);
                            return 0;
                        }
                        $res = array("NOM" => $nom, "PRENOM" => $prenom, "ID_PARENT" => $idParent, "CODE_RETOUR" => 1);
                        echo json_encode($res);
			break;
	}

        $parent->_parent_class();
?>